package cn.xopencode.appletweb.controller.record.kvoperation;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.rpc.kvoperation.dto.*;
import cn.xopencode.recordservice.rpc.kvoperation.vo.KvOperationRecordCreateVO;
import cn.xopencode.recordservice.rpc.kvoperation.vo.KvOperationRecordNextVO;
import cn.xopencode.recordservice.rpc.kvoperation.vo.KvOperationRecordPageVO;
import cn.xopencode.recordservice.rpc.kvoperation.vo.KvOperationRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "10KV操作室巡检记录 API")
@RestController
@RequestMapping("/kvoperation")
@Validated
public class KvOperationRecordController {
    /**
     * 根据查询条件分页获取所有的10KV操作室巡检记录
     * @param pageDTO
     * @return
     */
    @PostMapping("/getAllByQuery")
    @ApiOperation("根据查询条件分页获取所有的10KV操作室巡检记录")
    public CommonResult<PageResult<KvOperationRecordPageVO>> getPageKvOperationRecord(KvOperationRecordPageDTO pageDTO){
        PageResult<KvOperationRecordPageVO> result = new PageResult<>();
        List<KvOperationRecordPageVO> list = new ArrayList<>();

        KvOperationRecordPageVO vo = new KvOperationRecordPageVO();
        vo.setInspectionTime(new Date());
        vo.setEmpRels("张三、李四");
        list.add(vo);
        KvOperationRecordPageVO vo2 = new KvOperationRecordPageVO();
        vo2.setInspectionTime(new Date());
        vo2.setEmpRels("王一");
        list.add(vo2);
        result.setList(list);
        return null;
    }

    /**
     *  新增10KV操作室巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新增10KV操作室巡检记录")
    public CommonResult<KvOperationRecordCreateVO> createKvOperationRecord(@Valid KvOperationRecordCreateDTO roomDTO){
        KvOperationRecordCreateVO vo = new KvOperationRecordCreateVO();
        vo.setRecordCode("A0001");
        return CommonResult.success(vo);
    }

    /**
     *  新增 SF6气体密度继电器巡检记录 中的下一组数据
     * @param createDTO
     * @return
     */
    @PostMapping("/addNextLine")
    @ApiOperation("新增 10KV操作室巡检记录 下一组数据")
    public CommonResult<Integer> createKvOperationRecordNextLine(@Valid KvOperationRecordNextCreateDTO createDTO){
        //下一组保存时需要检查是否重复
        return CommonResult.success(1);
    }


    /**
     * 根据id获取配电室详细
     * @param recordId
     * @return
     */
    @GetMapping("/getById")
    @ApiOperation("根据id获取配电室详细")
    public CommonResult<KvOperationRecordVO> getKvOperationRecordById(String recordId){
        KvOperationRecordVO vo = new KvOperationRecordVO();
        vo.setEmpNames("张三");
        vo.setId("12321");
        vo.setPdroomName("测试");
        vo.setDayShift(true);
        vo.setLeaderDeal(true);
        vo.setNoticeLeader(true);
        vo.setRemark("备注");
        vo.setInspectionTime(new Date());
        vo.setNum(001);
        vo.setLineName("线路一");
        vo.setRecordCode("123");
        vo.setVoltageA(10.01);
        vo.setVoltageB(10.02);
        vo.setVoltageC(10.03);
        vo.setCurrentA(10.04);
        vo.setCurrentC(10.05);

        return CommonResult.success(vo);
    }

    /**
     * 根据记录标识、下一组的排序，获取10KV操作室巡检记录中下一组的详细
     * @param recordCode
     * @param recordSeq
     * @return
     */
    @GetMapping("/getNextById")
    @ApiOperation("根据记录标识、下一组的排序，获取10KV操作室巡检记录中下一组的详细")
    public CommonResult<KvOperationRecordNextVO> getKvOperationRecordNextById(String recordCode, String recordSeq){
        KvOperationRecordNextVO nextVO = new KvOperationRecordNextVO();
        nextVO.setPdroomName("测试");
        nextVO.setDayShift(true);
        nextVO.setLeaderDeal(true);
        nextVO.setNoticeLeader(true);
        nextVO.setRemark("备注");
        nextVO.setNum(001);
        nextVO.setLineName("线路一");
        nextVO.setRecordCode("123");
        nextVO.setVoltageA(10.01);
        nextVO.setVoltageB(10.02);
        nextVO.setVoltageC(10.03);
        nextVO.setCurrentA(10.04);
        nextVO.setCurrentC(10.05);
        return CommonResult.success(nextVO);
    }

    /**
     *  更新 10KV操作室巡检记录
     * @param updateDTO
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("更新 10KV操作室巡检记录")
    public CommonResult<Integer> updateKvOperationRecord(@Valid KvOperationRecordUpdateDTO updateDTO){
        return CommonResult.success(1);
    }

    /**
     *  更新 10KV操作室巡检记录 中的下一组数据
     * @param createDTO
     * @return
     */
    @PostMapping("/udpateNextLine")
    @ApiOperation("更新10KV操作室巡检记录 下一组数据")
    public CommonResult<Integer> updateKvOperationRecordNextLine(@Valid KvOperationRecordNextUpdateDTO createDTO){
        //下一组保存时需要检查是否重复
        return CommonResult.success(1);
    }
}
